
--[[
1 所有对象的基类

--]]
local Object = require "object"

--回调的好手
function handler(obj, method)
    return function(...)
        if not method then
            g.log:error("handler:", obj:getObjName(), method)
            return
        end
        return method(obj, ...)
    end
end

--新建一个对象
function new(mod_name, ...)
    local Class = require(mod_name)
    if Class and Class.isObject then
        -- print("class new " .. mod_name)
        local obj = Class:new(...)
        obj:setModuleName(mod_name)
        if g and type(g) == "table" and g.addObj then
            g.addObj(obj)
        else
            error("g is not ready ! " .. mod_name .. " error")
        end
        return obj
    end
    g.log:error("new class error: " .. mod_name)
    return nil
end

--声明一个类，继承Object
function class(name)
    local cls = Object:extend(name)
    return cls
end


